#ifndef WORKUI_H
#define WORKUI_H
#include"result.cpp"
#include <QMainWindow>
#include "mapwidget.h"
#include<QtNetwork/QUdpSocket>
#include<QtNetwork/QNetworkDatagram>

namespace Ui {
class WorkUI;
}

class WorkUI : public QMainWindow
{
    Q_OBJECT

public:
    explicit WorkUI(QWidget *parent,QString nn,QString id,QUdpSocket* udp);
    ~WorkUI();
    QPoint nowlocal;
    QPoint finallocal;
    QList<long long> findNearestAvailableCarsForOrder(
        long long orderId,
        const QMap<long long, QPoint>& carFreeMap,
        const QMap<long long, QPoint>& orderStartMap,
        const QMap<long long, int>& orderWeightsMap,
        const QMap<long long, int>& carCapacitiesMap
    );
    void closeEvent(QCloseEvent* e);
private slots:
    void on_locationButton_clicked();

    void on_finallButton_clicked();
    void changeposact();

    void Udphandle();
    void on_locationButton_2_clicked();

    void on_locationButton_3_clicked();

private:
    Ui::WorkUI *ui;
    QString name;
    QUdpSocket* udp;
    QString ID;
    QString orderid;
    QList<long long> carls;
};
struct CarDistance {
    long long carId;
    double distance;

    // 用于排序的比较运算符，使 std::sort 能按距离升序排列
    bool operator<(const CarDistance& other) const {
        return distance < other.distance;
    }
};

#endif // WORKUI_H
